package org.reliablesource.prism.gef.editor.commands;

import org.eclipse.gef.commands.Command;
import org.reliablesource.prism.core.IPrismScreen;
import org.reliablesource.prism.gef.editor.model.ScreenAdapter;


/**
 * @author Dennis Park
 *
 */
public class LoadBackgroundImageCommand extends Command {

	private ScreenAdapter screen;
	private String path;
	private String oldPath;
	/**
	 * 
	 */
	public LoadBackgroundImageCommand(final ScreenAdapter _screen, final String path) {
		super();
		this.path = path;
		this.screen = _screen;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#execute()
	 */
	public void execute() {
		redo();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#redo()
	 */
	public void redo() {
		this.oldPath = (String)this.screen.getPropertyValue(IPrismScreen.IMAGE_PATH);
		this.screen.setPropertyValue(IPrismScreen.IMAGE_PATH, this.path);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#undo()
	 */
	public void undo() {
		this.screen.setPropertyValue(IPrismScreen.IMAGE_PATH, this.oldPath);
	}

}
